import 'package:flutter/material.dart';

class FunctionButtonBar extends StatelessWidget {
  final Function() onCapture;
  final Function() onRecord;
  final Function() onTalk;
  final Function() onWarning;
  final Function() onTogglePTZ;
  final bool isPlaying;
  final bool isLoading;

  const FunctionButtonBar({
    super.key,
    required this.onCapture,
    required this.onRecord,
    required this.onTalk,
    required this.onWarning,
    required this.onTogglePTZ,
    required this.isPlaying,
    this.isLoading = false,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      padding: const EdgeInsets.symmetric(vertical: 12),
      child: GridView.count(
        shrinkWrap: true,
        crossAxisCount: 3,
        childAspectRatio: 1.5,
        physics: const NeverScrollableScrollPhysics(),
        children: [
          // 抓拍
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              IconButton(
                icon:
                    const Icon(Icons.camera_alt, color: Colors.black, size: 24),
                onPressed: !isLoading && isPlaying ? onCapture : null,
                disabledColor: Colors.grey,
              ),
              const Text('抓拍',
                  style: TextStyle(color: Colors.black, fontSize: 10)),
            ],
          ),

          // 录像
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              IconButton(
                icon: const Icon(Icons.videocam, color: Colors.black, size: 24),
                onPressed: !isLoading && isPlaying ? onRecord : null,
                disabledColor: Colors.grey,
              ),
              const Text('录像',
                  style: TextStyle(color: Colors.black, fontSize: 10)),
            ],
          ),

          // 语音对讲
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              IconButton(
                icon: const Icon(Icons.mic, color: Colors.black, size: 24),
                onPressed: !isLoading && isPlaying ? onTalk : null,
                disabledColor: Colors.grey,
              ),
              const Text('对讲',
                  style: TextStyle(color: Colors.black, fontSize: 10)),
            ],
          ),

          // 声光警告
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              IconButton(
                icon: const Icon(Icons.warning, color: Colors.red, size: 24),
                onPressed: !isLoading && isPlaying ? onWarning : null,
                disabledColor: Colors.grey,
              ),
              const Text('警告',
                  style: TextStyle(color: Colors.black, fontSize: 10)),
            ],
          ),

          // 云台控制
          Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              IconButton(
                icon: const Icon(Icons.gamepad, color: Colors.black, size: 24),
                onPressed: !isLoading && isPlaying ? onTogglePTZ : null,
                disabledColor: Colors.grey,
              ),
              const Text('云台',
                  style: TextStyle(color: Colors.black, fontSize: 10)),
            ],
          ),
        ],
      ),
    );
  }
}
